<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .router-link-active{
      background: red;
    }
  </style>
</head>
<body>
  <div id="app">
   
    <router-view></router-view>
    <hr>
    <router-view name="b"></router-view>
    <hr>
    <router-view name="c"></router-view>
  </div>
  <script src="vue.js"></script>
  <script src="vue-router.js"></script>
  <script>
    /* 
    
    /home home页
    /new news页
    /about about
     */
    const Home = {
      template: `
        <div>
          <h1> home页 </h1>
          {{ $route.params.a }}
        </div>
      `
    }
    const Home2 = {
      template: `
        <div>
          <h1> home2 </h1>
        </div>
      `
    }
    const Home3 = {
      template: `
        <div>
          <h1> Home3 </h1>
        </div>
      `
    }
   
    const routes = [ // 路由规则
      {
        path: '/',
        redirect: '/home'
      },
      {
        path: '/home',
        alias:'/news',
        name: '首页',
        components: {
          default: Home,
          b: Home2,
          c: Home3
        }
      }
    ]
    const router = new VueRouter({
      routes
    })
    const vm = new Vue({
      el: '#app',
      router
    })
  </script>
</body>
</html>